package com.yubest.dynamicdatasource.controller;

import com.yubest.dynamicdatasource.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class UserInfoController {

    @Autowired
    @Qualifier("userInfoService1Impl")
    private UserInfoService userInfoService1;

    @Autowired
    @Qualifier("userInfoService2Impl")
    private UserInfoService userInfoService2;

    @Autowired
    @Qualifier("userInfoService3Impl")
    private UserInfoService userInfoService3;

    @GetMapping(value = "/getUsers")
    public Object getInfo() {
        Map<String, Object> data = new HashMap<>();
        data.put("master", userInfoService1.getAll());
        data.put("slave", userInfoService2.getAll());
        data.put("db3", userInfoService3.getAll());
        return data;
    }
}
